<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>流程处理</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>
<body class="iframeBody">
    <div class="Wrapper">
        <div>
        	<div align="left">
        		<span>&nbsp;&nbsp;&nbsp;&nbsp;流程编号:</span><span style="color: red;">&nbsp;&nbsp;${procNo }</span>
        	</div>
        	<div align="left" class="btnsBox">
                <input name="processDefinitionIdNm" id="processDefinitionId" type="text" style="display: none;" value="${processDefinitionId}"/>
                <input name="processInstanceIdNm" id="processInstanceId" type="text" style="display: none;" value="${processInstanceId}"/>
                <input name="taskIdNm" id="taskId" type="text" style="display: none;" value="${taskId}"/>
                <input name="assignableIdNm" id="assignableId" type="text" style="display: none;" value="${assignable}"/>
                <input name="formUrlIdNm" id="formUrlId" type="text" style="display: none;" value="${formUrl}"/>
                <input name="processDefinitionIdNm" id="processDefinitionId" type="text" style="display: none;" value="${processDefinitionId}"/>
                <input name="processDefinitionKeyIdNm" id="processDefinitionKeyId" type="text" style="display: none;" value="${processDefinitionKey}"/>
                <input name="taskDefKeyIdNm" id="taskDefKeyId" type="text" style="display: none;" value="${taskDefKey}"/>
                <input name="flowPicUrlIdNm" id="flowPicUrlId" type="text" style="display: none;" value="${flowPicUrl}"/>
                <input name="businessKeyIdNm" id="businessKeyId" type="text" style="display: none;" value="${businessKey}"/>
                <input name="taskTypeIdNm" id="taskTypeId" type="text" style="display: none;" value="${taskType}"/>
                <input name="taskStatusIdNm" id="taskStatusId" type="text" style="display: none;" value="${taskStatus}"/>
                <input name="assigneeIdNm" id="assigneeId" type="text" style="display: none;" value="${assignee}"/>
                <input name="businessType" id="businessType" type="text" style="display: none;" value=""/>
                <input name="originTaskIdNm" id="originTaskId" type="text" style="display: none;" value="${originTaskId}"/>
                <input name="beanNameNm" id="beanNameId" type="text" style="display: none;" value="${beanName}"/>
                <input name="taskDefKeyNm" id="taskDefKeyNmId" type="text" style="display: none;" value="${taskDefKeyNm}"/>
                <input name="grpShr" id="grpShrId" type="text" style="display: none;" value="${grpShr}"/>
                <input name="onlySaveBtn" id="onlySaveBtnId" type="text" style="display: none;" value="${onlySave}"/>
                <span name="flowListIdNm" class="Hide" id="flowListId" style="display: block;" >${flowList}</span>
            </div>
            <div id="pageInTab" class="pageInTab">
                <div tabid="tabA" title="任务处理" lselected="true">
                    <form id="formSet1">
                        <div class="fieldset1 tabel_col clearFix noBorder">
                            <div class="caption">
                                <span class="title">签字信息</span>
                            </div>
                            <div id="div_flow_task_info_h_id"></div>
                        </div>
                    </form>
                </div>
                <div tabid="tabB" title="附加信息">
                    <iframe frameborder="0" name="tabB" id="tabB" src=""></iframe>
                </div>
                <div tabid="tabC" title="流程跟踪" >
                    <iframe frameborder="0" name="tabC" id="tabC" src=""></iframe>
                </div>
            </div>
        </div>
    </div>

    <script>
    var pageInApp={}; // to 下一级子窗口 接口
    var pageInTab=null;
    var loadedTabs=[]
    $(function() {
    	initTab();
    	initFlowTaskInfoH();
    });
    
    //初始化流程历史节点信息
    function initFlowTaskInfoH(){
    	var _taskId = $("#taskId").val();
    	var _processDefinitionId = $("#processDefinitionId").val();
    	var _processInstanceId = $("#processInstanceId").val();
    	var _originTaskId = $("#originTaskId").val();
    	var parms = {
    			taskId:_taskId,
    			processDefinitionId:_processDefinitionId,
    			processInstanceId:_processInstanceId,
    			originTaskId:_originTaskId
    	}
    	var _url = '<%=path%>/flow/flow/initFlowTaskInfoListWithNext.do';
		AjaxUtils.ajaxGet(_url, parms, function(msg){
			if(msg.success == 1 && msg.data){
                msg.data = SqHTMLDecodeObj(msg.data);
				 var html = "<div class=\"sectionBox\"><div class=\"recordTask\">";//sectionBox start
   			  $.each(msg.data, function (n, value) {
   				  html+='<div class=\"recordBox\" >'//recordBox start
   				  	  //这里做个处理,要是结束节点则不显示操作人
   				  	  var content = value.taskTm + ' [' + value.opUsrNm + ']' + value.opRlNm;
   				  	  if(FlowConstant.FLOW_TASK_ACTIVITY_TYPE_END == value.activityType){
   				  		content = "";//清空
   				  	  }
   	                  html+='<div class=\"rcTit\">' + content + ' : ' + value.outgoingFlow + '</div>';
   	                  html+="<div class=\"rcBody\">";//rcBody start
   	                  if(StringUtils.isNotEmpty(value.taskOpinion) && value.taskOpinion != "null"){
   	                  	html+='<div>' + value.taskOpinion + '</div>';
   	               	  }else{
   	               		html+='<div>&nbsp;</div>';
   	               	  }
   	                  //判断是否有附件,如果有则加入附件
   	                  html+="<div>";//div 1 start
   	                  if(value.attchmntList){
   	                	  $.each(value.attchmntList, function (nt, valuet) {
   	                		  	//判断是否是图片,如果是图片则加入target属性
   	                		  	if(StringUtils.isNotEmpty(valuet.filePath)){
   	                		  		//html+='<a class="fileLink" target="_blank" href="'+'<%=path%>/system/sysulfilesrec/downLoad.do?fileName='+ valuet.fileNm+'&filePath='+ valuet.filePath +'">'+ valuet.fileNm +'</a>';
   	                		  		html+="&nbsp;&nbsp;&nbsp;&nbsp;";
   	                		  		try
		   	                		{
		   	                		  	var extStart=valuet.filePath.lastIndexOf(".");
	   	                		    	var ext=valuet.filePath.substr(extStart,valuet.filePath.length).toUpperCase();
			   	                		if(ext!=".BMP"&&ext!=".PNG"&&ext!=".GIF"&&ext!=".JPG"&&ext!=".JPEG"){
			   	                			html+="<a target='_blank' class='fileLink' href='"+valuet.filePath+"'>"+valuet.fileNm+"</a>";
			   	                		}else{
			   	                			html+="<a target='_blank' class='fileLink' href='"+valuet.filePath+"'>"+valuet.fileNm+"</a>";
			   	                		}
		   	                		}
		   	                		catch(err)
		   	                		{
		   	                			html+="<a class='fileLink' target='_blank' href='"+valuet.filePath+"'>"+valuet.fileNm+"</a>";
		   	                		}
   	                		  	}
	    	              });
   	                  }
   	                  html+="</div>";//div 1 end
   	                  html+="</div>";//rcBody end
   	                  html+='</div>';//recordBox end
   			  });
   			  html+='</div></div>';//sectionBox end
   			  $("#div_flow_task_info_h_id").empty();
   			  $("#div_flow_task_info_h_id").html(html);
			 }else{
				 UIUtils.alertError(msg.info);
			 }
			SetIframe_height();
   	    },true);
    	
    }
    
    //初始化Tab页
    function initTab(){
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onAfterSelectTabItem: function(tabid) {
                if (loadedTabs.indexOf(tabid)<0) {
                    loadedTabs.push(tabid);
                    var domain = "<%=path%>";
                	var _formUrl = $("#formUrlId").val();
                	if(StringUtils.isNotEmpty(_formUrl)){
                	   var _businessKey = $("#businessKeyId").val();
                	   var _processInstanceId = $("#processInstanceId").val();
                	   var _taskId = $("#taskId").val();
                	   var _taskDefKey = $("#taskDefKeyId").val();
                	   var _taskDefKeyNm = $("#taskDefKeyNmId").val();
                		_formUrl = /* domain +  */_formUrl + _businessKey + "&processInstanceId="+_processInstanceId+"&taskId="+_taskId+"&taskDefKey="+_taskDefKey+"&taskNm="+_taskDefKeyNm+"";
                	}
                    switch (tabid){
                        case "tabB":
                        	if(StringUtils.isNotEmpty(_formUrl)){
                            	pageInTab.setTabItemSrc(tabid, _formUrl);
                        	}
                            break;
                        case "tabC":
                        	var flowPicURL = $("#flowPicUrlId").val();
                            pageInTab.setTabItemSrc(tabid, flowPicURL);
                            break;
                    }
                };
                SetIframe_height();
            }
        });

        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });
    }
    </script>
</body>
</html>